package com.lhf.dajiuye.service.dict.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lhf.dajiuye.bean.dict.Dict;
import com.lhf.dajiuye.mapper.dict.DictMapper;
import com.lhf.dajiuye.service.dict.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {
    @Autowired
    private DictMapper dictMapper;
    /**
     * 根据type获取字典Dict list
     * @param type
     * @return
     */
    @Override
    public List<Dict> getDictListByType(String type) {
        return dictMapper.getDictListByType(type);
        //return baseMapper.selectList(new QueryWrapper<Dict>().eq("type", type));
    }

    /**
     * 根据parentId获取字典Dict list
     * @param parentId
     * @return
     */
    @Override
    public List<Dict> getDictListByPid(String parentId) {
        return dictMapper.getDictListByPid(parentId);
        //return baseMapper.selectList(new QueryWrapper<Dict>().eq("parentId", parentId));
    }

    /**
     * 根据type获取字典Dict listTree
     * @param type
     * @return
     */
    @Override
    public List<Dict> getDictListTreeByType(String type){
        return dictMapper.getDictListTreeByType(type);
        //return baseMapper.selectList(new QueryWrapper<Dict>().eq("type", type));
    }

    /**
     * 根据id获取字典Dict
     * @param id
     * @return
     */
    @Override
    public Dict getDictById(String id) {
        return dictMapper.getDictById(id);
        //return baseMapper.selectOne(new QueryWrapper<Dict>().eq("id", id));
    }

}
